//
//  NSString+TextAdaption.m
//  MirrorCharge
//
//  Created by dllo on 16/10/18.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "NSString+TextAdaption.h"

@implementation NSString (TextAdaption)

/** 计算文字高度 */
- (CGFloat)calculateWordsHeightWithFontSize:(CGFloat)size andWidth:(CGFloat)width
{
    CGRect rect = [self boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:size]} context:nil];
    
    return ceilf(CGRectGetHeight(rect));
}

@end
